package test;

import java.util.Arrays;

import comment.Comment;

/**
 *create by tbj
 */
public class MyMerge {
	private static void merge(int[] a,int l,int mid,int r){
		int[] b=Arrays.copyOfRange(a, l, r+1);
		int i=l;
		int j=mid+1;
		for(int k=l;k<=r;k++){
			if(i > mid){
				a[k]=b[j-l];
				j++;
			}else if(j > r){
				a[k]=b[i-l];
				i++;
			}else if(b[i-l]<b[j-l]){
				a[k]=b[i-l];
				i++;
			}else{
				a[k]=b[j-l];
				j++;
			}
		}
	}
	private static void _sort(int[] a,int l,int r){
		if(l >= r){
			return ;
		}
		int mid = l+(r - l)/2;
		_sort(a, l, mid);
		_sort(a, mid+1, r);
		merge(a,l,mid,r);
	}
	public static void sort(int[] a){
		int n = a.length;
		_sort(a,0,n-1);
	}
	public static void main(String[] args) {
		int[] a=Comment.getSortIntArr();
		MyMerge.sort(a);
		for (int i : a) {
			System.out.print(i+" ");
		 }
	}
}
